{% extends "wakawaka/base.html" %}

{% load i18n %}
{% load group_tags %}

{% block extrahead %}
    {{ block.super }}
    {# Add support for the Universal Edit Button #}
    {% if perms.wakawaka.change_wikipage %}
    <link rel="edit" title="{% trans "Edit this page" %}" href="{% groupurl wakawaka_edit group slug=page.slug %}" />
    {% endif %}
{% endblock %}

{% block head_title %}
    {% if page.is_initial %}
        {% blocktrans with page.slug as slug %}Add {{ slug  }}{% endblocktrans %}
    {% else %}
        {% blocktrans with page.slug as slug %}Edit {{ slug  }}{% endblocktrans %}
    {% endif %}
{% endblock %}

{% block body %}
    <h1>
        {% if page.is_initial %}
            {% blocktrans with page.slug as slug %}Add {{ slug  }}{% endblocktrans %}
        {% else %}
            {% blocktrans with page.slug as slug %}Edit {{ slug  }}{% endblocktrans %}
        {% endif %}
    </h1>
    
    {% if rev.is_not_current %}
    <p class="revert-warning">{% trans "You are editing an revision which is not the latest!" %}</p>
    {% endif %}
    
    {% if is_locked and have_lock %}
    <p class="lock-notice">{% trans "The page is locked for you." %}</p>
    <form class="wakawaka_edit_form" method="POST" action="">
        {% csrf_token %}
        {{ form.as_p }}
        <p>
            <input type="submit" value="{% trans "Save changes" %}" />
            {% trans "or" %} <a href="
            {% if page.is_initial %}
                javascript:window.history.go(-1);
            {% else %}
                ?cancel_lock=true
            {% endif %}
            ">{% trans "Cancel" %}</a>
        </p>
    </form>
    {% else %}
    {% blocktrans with lock_timestamp|timesince as lock_timestamp %}The page is locked for {{ lock_owner }} since about {{ lock_timestamp }}.{% endblocktrans %}
    {% if allowed_to_reset %}<a href="?reset_lock=true" title="Locked for another {{ lock_ttl|timeuntil }}">{% trans "Reset lock" %}</a>{% endif %}
    <div class="page">
      {% include "wakawaka/page_content.html" %}
    </div>
    {% endif %}
    
    {% if not page.is_initial and delete_form %}
    <form class="wakawaka_delete_form" method="POST" action="" onsubmit="return confirm('{% trans "Please confirm deletion" %}');">
        {% csrf_token %}
        {{ delete_form.as_p }}
        <p>
            <input type="submit" value="{% trans "Delete" %}" />
        </p>
    </form>
    {% endif %}
    
    <h2>{% trans "Revisions for this page" %}</h2>
    
    {% include "wakawaka/revision_table.html" %}
{% endblock %}
